package TestEmo;

public class Computer {
    public void openComputer(){
        System.out.println("打开电脑");
    }
    public void closeComputer(){
        System.out.println("关闭电脑");
    }
    public  void print(USB usb){
        usb.openChick();
        if(usb instanceof Mouse){//判断
            Mouse mouse = (Mouse) usb;
            mouse.crickMouse();
        }
        else if(usb instanceof KeyBoard){
            KeyBoard keyBoard = (KeyBoard) usb;
            keyBoard.input();
        }
        usb.closeChick();
    }
    public static void main(String[] args) {
    Computer computer = new Computer();
    computer.openComputer();
    computer.print(new KeyBoard());
    computer.print(new Mouse());
    computer.closeComputer();
    }
}
